import java.security.PublicKey;

/**
 * <p>
 * 交易输出
 * </p>
 *
 * @author KANLEI
 * @email freefree.me@qq.com
 * @create 2020-10-29
 */
public class TransactionOutput {

    public String id;
    // new coins owner
    public PublicKey receiver;
    // receiver coins
    public double value;
    public String parentTransactionId;

    public TransactionOutput(PublicKey receiver, double value, String parentTransactionId) {
        this.receiver = receiver;
        this.value = value;
        this.parentTransactionId = parentTransactionId;
        this.id = StringUtils.applySHA256(StringUtils.getStringFromKey(receiver) +
                value +
                parentTransactionId);
    }
    // 是否被挖了
    public boolean isMine(PublicKey key) {
        return key == receiver;
    }

}
